/**********************************************************
 * File: i2cDevice.h
 * Project: i2cDevice.h
 * 
 * Description: Class Represents a Device on the I2c Bus
 *
 */


#ifndef __I2C_DEVICE_H__
#define __I2C_DEVICE_H__
#include <string>

class i2cNet;

class i2cDevice
{
public:
    typedef unsigned long Address;
 
    static const unsigned char NULL_DEVICE_ID;
    static const std::string NULL_DEVICE_NAME;
    static const i2cDevice NULL_DEVICE;

    i2cDevice(const std::string& name, unsigned char id);
    i2cDevice(const i2cDevice& device);
    i2cDevice();
    virtual ~i2cDevice();
    const std::string& name() const;
    
    i2cNet* getNetwork();

    void operator=(const i2cDevice&);
    int operator==(const i2cDevice&) const;
    int operator!=(const i2cDevice&) const;

    unsigned char readRegister8(Address address);

    unsigned short readRegister16(Address address);

    unsigned short readRegister32(Address address);

    unsigned readMemory(Address address, void* buffer, unsigned long bufferLen);

    void writeRegister8(Address address, unsigned char value);

    void writeRegister16(Address address, unsigned short value);

    void writeRegister32(Address address, unsigned long value);

    void writeMemory32(Address address, const void* buffer, unsigned long bufferLen);
 
    
private:
    std::string m_name;
    unsigned char m_id;
    i2cNet* m_network;
    friend class i2cNet;
};




#endif /* __I2C_NET_H__ */

